export default {
    style: { "margin-bottom": "10px", "display": "inline-block" },
    buttons: [
        {
            kind: "add",
            icon: "el-icon-document-add",
        },
        {
            kind: "del",
            icon: "el-icon-delete",
        },
        {
            kind: "reset",
            icon: "el-icon-refresh-left",
        },
        {
            kind: "save",
            type: "danger",
            icon: "el-icon-upload",
        },
        {
            kind: "flow",
            type: "primary",
            text: "审批",
            icon: "el-icon-circle-check",
            click: function () {
                let dataset = this.source;
                let data = dataset.data;
                if (data.length == 0) {
                    this.$message({
                        message: '没有找到要审批的数据',
                        type: 'warning'
                    });
                    return;
                }
                if (this.source.getDirty()) {
                    this.$message({
                        message: '请先保存数据，再审批',
                        type: 'warning'
                    });
                    return;
                }
                let fnumer = data[0].FNUMBER;

                let toolbar = this
                this.$confirm(`确定审批【${fnumer}】吗?审批后将无法删除和修改!`, '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    debugger;
                    for (let i = 0; i < data.length; i++) {
                        let item = data[i];
                        item.FAUDIT = 0;
                    }
                    dataset.save().then(res => {
                        toolbar.$message({
                            message: `【${fnumer}】审批成功`,
                            type: 'success'
                        });
                        this.context.closepage()
                    })
                }).catch(() => {

                });


            }
        }
        // ,{
        //     kind: "print",
        //     type: "success",
        //     text: "打印",
        //     icon: "el-icon-printer",
        // }

    ],
}